<#include "../common/nolayout.ftl"/>
<@html js_=['life/friendly_link.js']>
<style>
    .thumbBox{ height:151px; overflow:hidden; border:1px solid #e6e6e6; border-radius:2px; cursor:pointer; position:relative; text-align:center; line-height:153px;}
    .thumbImg{ max-width:100%; max-height:100%; border:none;}
    .thumbBox:after{ position:absolute; width:100%; height:100%;line-height:153px; z-index:-1; text-align:center; font-size:16px; content:"封面图"; left:0; top:0; color:#9F9F9F;}
</style>
<body class="childrenBody">
    <blockquote class="layui-elem-quote news_search">
        <form class="layui-form" id="listForm" action="${root}/m/friendly/link/list" method="post">
            <input type="hidden" name="number" id="number" value="1"/>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" value="" placeholder="请输入公司名" name="company" class="layui-input ">
                </div>
                <div class="layui-input-inline">
                    <input type="text" value="" placeholder="请输入链接地址" name="url" class="layui-input ">
                </div>
                <a class="layui-btn search_btn" lay-submit lay-filter="queryForm">查询</a>
                <div class="layui-inline">
                    <a class="layui-btn layui-btn-normal addBtn">添加链接</a>
                </div>
            </div>
        </form>
    </blockquote>
    <div class="layui-form users_list">
        <table class="layui-table">
            <thead>
            <tr>
                <th>公司名</th>
                <th>联系方式</th>
                <th>链接图片</th>
                <th>链接地址</th>
                <th>排序</th>
                <th>状态</th>
                <th>添加时间</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody id="listDataBody"></tbody>
        </table>
    </div>
    <div  id="page"></div>
</body>

<script type="text/html" id="addLink">
    <form class="layui-form">
        <input type="hidden" name="pic" id="pic"/>
        <div class="layui-form-item">
            <label class="layui-form-label">公司名</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input company" name="company" maxlength="64" placeholder="请输入公司名">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系方式</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input tel" name="tel" maxlength="64" placeholder="请输入联系方式">
            </div>
        </div>
        <div class="layui-form-item layui-row layui-col-xs12">
            <label class="layui-form-label">头像</label>
            <div class="layui-upload-list thumbBox mag0 magt3" style="border:1px solid #FFFFFF">
                <img class="layui-upload-img thumbImg" src="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">链接地址</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input url" name="url" maxlength="128" placeholder="请输入链接地址">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input desc" name="desc" maxlength="255" placeholder="请输入描述">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input sort" name="sort" maxlength="255" placeholder="请输入排序数字，数字越大越靠前,默认为1">
            </div>
        </div>
    </form>
</script>

<script id="dataListTpl" type="text/html">
    {{#  if(d.list!=null&&d.list.length> 0){ }}
    {{#  layui.each(d.list, function(index, item){ }}
    <tr>
        <td>{{item.company||''}}</td>
        <td>{{item.tel||''}}</td>
        <td>
            <a href="{{item.pic}}" target="_blank">
                <img src="{{item.pic}}">
            </a>
        </td>
        <td><a href="{{item.url||''}}" target="_blank">{{item.url||''}}</a></td>
        <td>
            {{item.sort}}
        </td>
        <td class="status">
            {{# if(item.status==0){ }}
            显示
            {{#} else{ }}
            隐藏
            {{# } }}
        </td>
        <td>{{ layui.util.toDateString(item.insertDate, 'yyyy-MM-dd HH:mm:ss') }}</td>
        <td>{{ layui.util.toDateString(item.lastDate, 'yyyy-MM-dd HH:mm:ss') }}</td>
        <td>
            <div class="layui-btn-container">
                <a class="layui-btn layui-btn-xs linkEdit" data-id="{{item.id}}">
                    <i class="layui-icon">&#xe642;</i>编辑</a>
                {{# if(item.status==0){ }}
                <a class="layui-btn layui-btn-xs layui-btn-danger linkHidden" data-id="{{item.id}}" onclick="updateLinkStatus('{{item.id}}',1)">
                    <i class="layui-icon">&#xe640;</i>隐藏</a>
                {{#} else{ }}
                <a class="layui-btn layui-btn-xs layui-btn-warm linkShow" data-id="{{item.id}}" onclick="updateLinkStatus('{{item.id}}',0)">
                    <i class="layui-icon">&#xe631</i>显示<a>
                {{# } }}
            </div>
        </td>
    </tr>
    {{#  }); }}
    {{#} else { }}
    <tr>
        <td colspan="6" style="text-align: center">无数据</td>
    <tr/>
    {{# }}}

</script>
</@html>